<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>优家购房系统 - 租户信息管理</title>
	<!-- 引入css -->
	<link href="css/bootstrap.min.css" rel="stylesheet" />
	<!-- 使用bootstrap前端框架，首先引入jquery -->
	<script type="text/javascript" src="js/jquery-3.3.1.js"></script>
	<!-- 引入js插件 -->
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<link rel="stylesheet" href="css/main.css">
	<link rel="stylesheet" href="lib/font-awesome/css/font-awesome.css">
	<script type="text/javascript">
		$(document).ready(function(){
			var status='${status}';
			var sex='${sex}';
			$("#test option").each(function(){
				if($(this).val()==status){
					$(this).attr("selected",true);
				}
			});
			//性别选中
			$("#test2 option").each(function(){
				if($(this).val()==sex){
					$(this).attr("selected",true);
				}
			});
		});
	</script>
	
	
</head>
<body style="background:url('image/bg2.jpg');background-size:cover;">
<div class="box">
	<h3>租户信息管理</h3>
	<div class="actions">
		<div>
			<a class="btn btn-primary" href="view/lessee/add.jsp">添加租户信息</a>
		</div>
		<div>
			<form action="LesseeServlet2" method="post">
				<input type="hidden" name="method" value="select">
				姓名:<input name="name" placeholder="租户姓名" value="${name}">
				电话:<input name="phone" placeholder="租户电话" value="${phone}">
				性别:<select name="sex" id="test2">
						<option value="">请选择</option>
						<option value="0">女</option>
						<option value="1">男</option>
					</select>
				身份证号码:<input name="idCard" placeholder="身份证号码" value="${idCard}">
				<button type="submit"><span class="glyphicon glyphicon-search" style="color:red;"></span></button>
			</form>
		</div>
	</div>

	<table class="list">
		<tr>
			<th>序号</th>
			<th>姓名</th>
			<th>电话</th>
			<th>性别</th>
			<th>籍贯</th>
			<th>身份证号码</th>
			<th>添加时间</th>
			<th>租户信息状态</th>
			<th>操作</th>
		</tr>
		<c:forEach items="${list }" var="lessee" varStatus="status">
		<tr>
			<td>${status.count }</td>
			<td>${lessee.l_name }</td>
			<td>${lessee.l_tel }</td>
			
			<c:if test="${lessee.l_sex eq '0'}">
				<td>女</td>
			</c:if>
			<c:if test="${lessee.l_sex eq '1'}">
				<td>男</td>
			</c:if>
			<td>${lessee.l_native_place }</td>
			<td>${lessee.l_id_card }</td>
			<td>${lessee.l_create_time }</td>
			<c:if test="${lessee.l_status==0 }">
				<td style="color:red;">已失效</td>
			</c:if>
			<c:if test="${lessee.l_status==1 }">
				<td style="color:blue;">正常</td>
			</c:if>
			<td>
				<a title="编辑" href="LesseeServlet2?method=glbi&id=${lessee.l_id }">
				<span class="glyphicon glyphicon-edit"></span>
				</a>
				&nbsp;&nbsp;
				<a title="删除"  onclick="confirmDelete(${lessee.l_id})">
				<span class="glyphicon glyphicon-trash"></span>
				</a>
			</td>
		</tr>
		</c:forEach>
	</table>
	<div>
		<c:url value="LesseeServlet2?method=select" var="forward">
			<c:param name="pageIndex" value="${pageIndex-1 }"></c:param>
			<c:param name="name" value="${name }"></c:param>
			<c:param name="phone" value="${phone }"></c:param>
			<c:param name="sex" value="${idCard }"></c:param>
		</c:url>
		<c:url value="LesseeServlet2?method=select" var="next">
			<c:param name="pageIndex" value="${pageIndex+1 }"></c:param>
			<c:param name="name" value="${name }"></c:param>
			<c:param name="phone" value="${phone }"></c:param>
			<c:param name="sex" value="${idCard }"></c:param>
		</c:url>
	</div>
	<div class="pager-info">
		<div>第 ${pageIndex }/${totalPages } 页 </div>
		<div>
			<ul class="pagination">
				<li class="paginate_button previous disabled ">
				<c:if test="${pageIndex >= 1 }">
					<a href="${forward }">上一页</a>
				</c:if>
				</li>
				<li class="paginate_button active">
					<form action="LesseeServlet2?method=select" method="post">
					<input type="hidden" name="name" value="${name }">
					<input type="hidden" name="phone" value="${phone }">
					<input type="hidden" name="sex" value="${sex }">
					请选择页码(第${pageIndex }页/共${totalPages }页)：
					<input name="pageIndex">
					<input type="submit" value="跳转">
					</form>
				</li>
				<li class="paginate_button next disabled">
					<c:if test="${pageIndex <= totalPages }">
				<a href="${next }">下一页</a>
				</c:if>
				</li>
			</ul>
		</div>
	</div>
</div>
<script src="lib/jquery/jquery.js"></script>
<script>
function confirmDelete(id){
	if (confirm("确定要删除码？")) {
		window.location="LesseeServlet2?method=delete&id="+id;
		return true;
	}
	return false;
}
</script>
</body>
</html>